//
//  Category.m
//  EasyTip
//
//  Created by Jeffrey Palm on 2/14/09.
//  Copyright 2009 Jeffrey Palm. All rights reserved.
//

#import "Category.h"
#import "Criteria.h"


@implementation Category

@synthesize next;

- (id)initWithName:(NSString*)theName {
	if (self = [super initWithName:theName]) {
		criteriaArray = [[NSMutableArray array] retain];
	}
	return self;
}

- (NSArray*) criteria {
	NSArray *res = [NSArray arrayWithArray:criteriaArray];
	return res;
}

- (Criteria*)add:(Criteria*)c {
	[criteriaArray addObject:c];
	return c;
}

- (Criteria*)addCriteria:(NSString*)name value:(int)v {
	return [self add:[[Criteria alloc] initWithNameAndValue:name value:v parent:self]];
}

- (Criteria*)addCriteria:(NSString*)name value:(int)v image:(NSString*)img {
	Criteria *c = [self addCriteria:name value:v];
	c.imageName = img;
	return c;
}

- (Criteria*)addCriteria:(NSString*)name value:(int)v description:(NSString*)desc {
	Criteria *c = [self addCriteria:name value:v];
	c.description = desc;
	return c;	
}

- (Criteria*)addCriteria:(NSString*)name value:(int)v image:(NSString*)img description:(NSString*)desc {
	Criteria *c = [self addCriteria:name value:v];
	c.imageName = img;
	c.description = desc;
	return c;		
}


- (int) criteriaCount {
	return [criteriaArray count];
}

- (Criteria*)criteriaAt:(int)index {
	return (Criteria*)[criteriaArray objectAtIndex:index];
}

- (void) dealloc {
	[criteriaArray release];
	[super dealloc];
}

@end
